#include"udpserver.hpp"

void print(std::string str)
{
    std::cout << "get a message：" << str << std::endl;
}

std::string my_cmd(std::string cmd)
{
    FILE* fp = popen(cmd.c_str(), "r");
    if(!fp)
    {
        perror("popen");
        exit(1);
    }
    std::string back;
    char buffer[SIZE] = {0};
    while(1)
    {
        char* ret = fgets(buffer, SIZE, fp);
        if(!ret) break;
        back += ret;
    }

    return back;
}

int main()
{
    udpserver us;
    us.init();

    us.run(my_cmd);
    
    return 0;
}